<?php 
namespace app\single\api;


use app\single\model\DayOnlineModel;
use app\single\model\LogGuildModel;
use Exception;
use think\Db;
use think\facade\Cache;
use think\facade\Log;

class LogGuild
{
    public function __construct()
    {
    }

    public function run($params)
    {
        $data["ret"] = 1;
        $maxValue = $params["max_value"] ?? 0;//最大值
        $limit = $params["limit"] ?? 10000;

        $model = new LogGuildModel();
        try {
            $payData = $model->where("id > $maxValue")->limit($limit)->order("id ASC")->select();
        } catch (Exception  $e) {
            Log::error($e->getMessage()."data====>".json_encode($data,true));
            return $data;
        }

        $returnData = [];
        foreach ($payData as $row) {
            $row["platform"] = PLATFORM;
            $row["single_id"] = $row["id"];
            $row["plat_server"] = PLAT_SERVER_ID;
            // $row["player_id"] = $row["role_id"];
            // $row["pay_month"] = date("Ym", $row["pay_time"]);
            unset($row["id"]);
            $returnData[] = $row;
        }

        $data["data"] = $returnData;
        return $data;
    }
}